from django.db import models
class Category(models.Model):
    cate_name =models.CharField(max_length=20,verbose_name="商品分类")
    class Meta:
        verbose_name ="商品分类"
        verbose_name_plural=verbose_name
    def __str__(self):
        return  self.cate_name

class Goods(models.Model):
    sku_name =models.CharField(max_length=100,verbose_name="商品名称")
    price =models.DecimalField(max_digits=13,decimal_places=2,verbose_name="商品价格")
    selling_price=models.DecimalField(max_digits=13,decimal_places=2,verbose_name="售价")
    img =models.CharField(max_length=200,verbose_name="商品主题")
    title = models.CharField(max_length=30,verbose_name="商品标题")
    instruction =models.TextField(verbose_name="商品描述")
    count =models.IntegerField(default=0,verbose_name="销量")
    cate =models.ForeignKey(Category,on_delete=models.CASCADE,verbose_name="种类")
    online =models.BooleanField(default=True,verbose_name="是否在售")
    stock = models.IntegerField(default=0, verbose_name="库存")
    class Meta:
        verbose_name="商品"
        verbose_name_plural=verbose_name
    def __str__(self):
        return self.sku_name

class GoodsImg(models.Model):
    img =models.CharField(max_length=200,verbose_name="图片地址")
    title =models.CharField(max_length=20,verbose_name="图片标题")
    goods =models.ForeignKey(Goods,on_delete=models.CASCADE)
    class Meta:
        verbose_name="商品图片"
        verbose_name_plural=verbose_name
    def __str__(self):
        return self.title

class Carousel(models.Model):
    imgPath = models.CharField(max_length=100,verbose_name="论插图地址")
    describes = models.CharField(max_length=20,verbose_name="论插图描述")
    class Meta:
        verbose_name = "论插图"
        verbose_name_plural = verbose_name
    def __str__(self):
        return self.describes


